from django.db import models
from utils.models import BaseModel


class Roles(BaseModel):
    """
    角色
    """
    roleName = models.CharField(verbose_name='角色', max_length=32, unique=True)
    # permissions = models.ManyToManyField('Permissions', verbose_name='权限',
    #                                      db_table='system_roles_permissions', blank=True)
    status = models.BooleanField(verbose_name='状态', max_length=64)
    desc = models.CharField(verbose_name='描述', max_length=521, blank=True, default='')

    objects = models.Manager()

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'system_roles'
        verbose_name = '角色'
        verbose_name_plural = verbose_name
        ordering = ['id']


class Departments(BaseModel):
    """
    组织架构 部门
    """
    name = models.CharField(verbose_name='部门', max_length=32, unique=True)
    fullName = models.CharField(verbose_name='部门全称', max_length=32, unique=True)
    status = models.BooleanField(verbose_name='状态', max_length=64)
    pid = models.ForeignKey('self', verbose_name='父部门', null=True, blank=True, on_delete=models.CASCADE)

    objects = models.Manager()

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'system_departments'
        verbose_name = '部门'
        verbose_name_plural = verbose_name
        ordering = ['id']
